package com.htzos.admin.log.controller;
import com.htzos.admin.log.bean.LogReqBase;
import com.htzos.common.tool.ExtQueryBean;
import com.htzos.base.parent.ctrl.BaseController;
import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.view.RedirectView;
import com.htzos.admin.log.service.LogReqBaseService;

@Controller
@RequestMapping("/logReqBase")
public class LogReqBaseController extends BaseController{

    @Resource
    LogReqBaseService logReqBaseService;

    @RequestMapping("/list")
    public ModelAndView list(HttpServletRequest request,LogReqBase condition, ExtQueryBean extQuery) {
        if(extQuery.getPageNum() == null) {
            extQuery.setSize(10);
            extQuery.setPageNum(1);
        }

        extQuery.setTotal(logReqBaseService.logReqBaseTotal(condition, extQuery));
        List<LogReqBase> list= logReqBaseService.logReqBaseList(condition, extQuery);
        request.setAttribute("list", list);
        request.setAttribute("condition", condition);
        request.setAttribute("extQuery", extQuery);
        request.getSession(true).setAttribute("conditionStr", condition);
        request.getSession(true).setAttribute("extQueryStr", extQuery);
        return new ModelAndView("admin/log/logReqBaseList");
    }

    @RequestMapping("/update")
    public ModelAndView update(HttpServletRequest request, LogReqBase logReqBase) {
        logReqBaseService.logReqBaseUpdate(logReqBase);
        return new ModelAndView(new RedirectView("list"), getSessionQueryString(request));
    }

    @RequestMapping("/updatePage")
    public String updatePage(HttpServletRequest request, String id) {
        LogReqBase logReqBase = logReqBaseService.logReqBaseGet(id);
        request.setAttribute("logReqBase", logReqBase);
        return "admin/log/logReqBaseUpdate";
    }

    @RequestMapping("/detail")
    public String detail(HttpServletRequest request, String id) {
        LogReqBase logReqBase = logReqBaseService.logReqBaseGet(id);
        request.setAttribute("logReqBase", logReqBase);
        return "admin/log/logReqBaseDetail";
    }

    @RequestMapping("/insert")
    public ModelAndView insert(HttpServletRequest request, LogReqBase logReqBase) {
        logReqBaseService.logReqBaseInsert(logReqBase);
        return new ModelAndView(new RedirectView("list"), getSessionQueryString(request));
    }
    @RequestMapping("/addPage")
    public String addPage() {
        return "admin/log/logReqBaseAdd";
    }

    @RequestMapping("/delete")
    public ModelAndView delete(HttpServletRequest request, LogReqBase logReqBase) {
        logReqBaseService.logReqBaseDelete(logReqBase);
         return new ModelAndView(new RedirectView("list"), getSessionQueryString(request));
    }
}